﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIAlert : MonoBehaviour {

	private CanvasGroup cc;

	public Text txtTitle;
	public Text txtContent;
	public Button btnOk;
	// Use this for initialization
	void Awake () {
		cc = this.gameObject.GetComponent<CanvasGroup>();

		btnOk.onClick.AddListener(delegate ()
		{
			this.Visible = false;
		});
	}

	public bool Visible
	{
		set
		{
			cc.alpha = value?1:0;
			cc.interactable = value;
			cc.blocksRaycasts = value;

		}
		get
		{
			return cc.alpha == 1 ? true : false;
		}
	}


	public void Show(string content,string title = "提示")
	{
		txtTitle.text = title;
		txtContent.text = content ;
		this.Visible = true;
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}
